package cn.youqu.happy.module.youqu.dal.mysql.systemActivity;

import java.util.*;

import cn.youqu.happy.framework.common.pojo.PageResult;
import cn.youqu.happy.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.youqu.happy.framework.mybatis.core.mapper.BaseMapperX;
import cn.youqu.happy.module.youqu.dal.dataobject.systemActivity.SystemActivityDO;
import org.apache.ibatis.annotations.Mapper;
import cn.youqu.happy.module.youqu.controller.admin.systemActivity.vo.*;

/**
 * 系统活动模板 Mapper
 *
 * @author 王其岩  20112001045
 */
@Mapper
public interface SystemActivityMapper extends BaseMapperX<SystemActivityDO> {

    default PageResult<SystemActivityDO> selectPage(SystemActivityPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SystemActivityDO>()
                .eqIfPresent(SystemActivityDO::getPid, reqVO.getPid())
                .likeIfPresent(SystemActivityDO::getActivityName, reqVO.getActivityName())
                .eqIfPresent(SystemActivityDO::getMaxPartners, reqVO.getMaxPartners())
                .eqIfPresent(SystemActivityDO::getMinPartners, reqVO.getMinPartners())
                .betweenIfPresent(SystemActivityDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(SystemActivityDO::getRemark, reqVO.getRemark())
                .orderByDesc(SystemActivityDO::getId));
    }

    default List<SystemActivityDO> selectList(SystemActivityExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SystemActivityDO>()
                .eqIfPresent(SystemActivityDO::getPid, reqVO.getPid())
                .likeIfPresent(SystemActivityDO::getActivityName, reqVO.getActivityName())
                .eqIfPresent(SystemActivityDO::getMaxPartners, reqVO.getMaxPartners())
                .eqIfPresent(SystemActivityDO::getMinPartners, reqVO.getMinPartners())
                .betweenIfPresent(SystemActivityDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .eqIfPresent(SystemActivityDO::getRemark, reqVO.getRemark())
                .orderByDesc(SystemActivityDO::getId));
    }

}
